<?php
namespace app\manage\controller;
use app\weixin\controller\Payment;
use Endroid\QrCode\QrCode; 
use app\manage\controller\Common;
use app\common\model\member\Payorder;
use app\common\model\member\MemberPayment as PaymentModel;
use app\common\model\member\Member as MemberModel;
use app\common\model\member\MoneyLog as MoneylogModel;
use app\common\model\member\MemberSmsLog as SmslogModel;
use app\common\model\member\MemberPaySms as SmspayModel;
class Money extends  Common{
   
   
    //支付页面
    public function index(){
    	
        $member_id=$this->request->post('member_id');
        $money=$this->request->post('money');
        $out_trade_no=time().rand(0,9999)
        $payment= new Payment;
        $result=$payment->unify($member_id,$money,$out_trade_no);
        $qrCode = new QrCode($result['code_url']);
        $code_url=$qrCode->writeDataUri();
        $this->assign('code_url',$code_url);
        $this->assign('out_trade_no',$out_trade_no);
    	return $this->fetch();
    }
    //充值页面
   
    public function recharge(){
		$member_id =   $this->member_info->member_id;
		if($this->request->method() == "POST"){
        }else{
			$this->assign('member_id',$this->member_info->member_id);
            $this->assign('moblie',$this->member_info->mobile);
			$this->assign('nick_name',$this->member_info->nick_name);
			$this->assign('real_name',$this->member_info->real_name);
			$this->assign('email',$this->member_info->email);
			$this->assign('qq',$this->member_info->qq);
			$this->assign('weixin',$this->member_info->weixin);
			$this->assign('nick_dllogo',$this->member_info->nick_dllogo);
			$this->assign('nick_dltitle',$this->member_info->nick_dltitle);
            return $this->fetch();
        }
    }
    //订单列表
    public function lists(){
		$member_id =  (int) $this->member_info->member_id;
		if($this->request->method() == "POST"){
        }else{
			$this->assign('member_id',$this->member_info->member_id);
            $this->assign('moblie',$this->member_info->mobile);
			$this->assign('nick_name',$this->member_info->nick_name);
			$this->assign('real_name',$this->member_info->real_name);
			$this->assign('email',$this->member_info->email);
			$this->assign('qq',$this->member_info->qq);
			$this->assign('weixin',$this->member_info->weixin);
			$this->assign('nick_dllogo',$this->member_info->nick_dllogo);
			$this->assign('nick_dltitle',$this->member_info->nick_dltitle);
			$this->assign('row',Payorder::all(null,true));
            return $this->fetch();
        }
    }
    /**
     * 检测是否支付成功
     *
     * @return int 0/1
     * @author 
     **/
    public function checkorder()
    {
        $out_trade_no=$this->request->post('out_trade_no');
        $order=Payorder::get(['out_trade_no'=>$out_trade_no]);
        return $order->state;
    }
    
}